package org.gdsdxy.pmmp.util;




import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;


public class HibernateUtil {
 private static SessionFactory sessionFactory;
 private static Configuration config = new Configuration().configure();
 static{
	 sessionFactory=config.buildSessionFactory();
 }
 
 public static SessionFactory getSessionFactory(){
	 if(sessionFactory==null)
		 sessionFactory=config.buildSessionFactory();
	 return sessionFactory;
 }
 
 
 public static Session createSession(){
	 return sessionFactory.openSession();
 }
 
 public static void closeSession(Session session){

		 if(session!=null)
			 session.close();
	
 }
}
